package com.liang.maogouyuyin.base.lzy
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding

abstract class LZYBaseFragment<VB : ViewBinding>: Fragment() {
    private var _binding: VB? = null
    protected val binding: VB
        get() = _binding!!

    private lateinit var rootView: ViewGroup
    private lateinit var rootLinearLayout: LinearLayout
    private lateinit var immersionView: View

    private var immersionEnabled = true // 默认为 true
    private var scrollEnabled = false

    abstract val bindingInflater: (LayoutInflater, ViewGroup?, Boolean) -> VB

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        _binding = bindingInflater(inflater, container, false)
        rootView = binding.root as ViewGroup
        return rootView
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initViews()
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }

    // 初始化视图
    abstract fun initViews()
}